home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / unix / sysv / sysv4 / __sysconf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-18  |  3.4 KB  |  180 lines

  1. /* Copyright (C) 1993 Free Software Foundation, Inc.
  2.    Contributed by Brendan Kehoe (brendan@zen.org).
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <ansidecl.h>
  20. #include <errno.h>
  21. #include <limits.h>
  22. #include <unistd.h>
  23. #include <stdio.h>
  24. #include <time.h>
  25. #include <sysconfig.h>
  26.  
  27. extern int EXFUN(__sysconfig, (int));
  28.  
  29. /* Get the value of the system variable NAME.  */
  30. long int
  31. DEFUN(__sysconf, (name), int name)
  32. {
  33.   switch (name)
  34.     {
  35.     default:
  36.       errno = EINVAL;
  37.       return -1;
  38.  
  39.     case _SC_ARG_MAX:
  40. #ifdef    ARG_MAX
  41.       return ARG_MAX;
  42. #else
  43.       return -1;
  44. #endif
  45.  
  46.     case _SC_CHILD_MAX:
  47. #ifdef    CHILD_MAX
  48.       return CHILD_MAX;
  49. #else
  50.       return -1;
  51. #endif
  52.  
  53.     case _SC_CLK_TCK:
  54.       return __sysconfig (_CONFIG_CLK_TCK);
  55.  
  56.     case _SC_NGROUPS_MAX:
  57. #ifdef    NGROUPS_MAX
  58.       return NGROUPS_MAX;
  59. #else
  60.       return -1;
  61. #endif
  62.  
  63.       /* Both of these are looking for _CONFIG_OPEN_FILES.  */
  64.     case _SC_OPEN_MAX:
  65.     case _SC_STREAM_MAX:
  66.       return __sysconfig (_CONFIG_OPEN_FILES);
  67.  
  68.     case _SC_TZNAME_MAX:
  69.       return __tzname_max ();
  70.  
  71.     case _SC_JOB_CONTROL:
  72. #ifdef    _POSIX_JOB_CONTROL
  73.       return 1;
  74. #else
  75.       return -1;
  76. #endif
  77.     case _SC_SAVED_IDS:
  78. #ifdef    _POSIX_SAVED_IDS
  79.       return 1;
  80. #else
  81.       return -1;
  82. #endif
  83.     case _SC_VERSION:
  84.       return _POSIX_VERSION;
  85.  
  86.     case _SC_PAGESIZE:
  87.       return __sysconfig (_CONFIG_PAGESIZE);
  88.  
  89.     case _SC_BC_BASE_MAX:
  90. #ifdef    BC_BASE_MAX
  91.       return BC_BASE_MAX;
  92. #else
  93.       return -1;
  94. #endif
  95.  
  96.     case _SC_BC_DIM_MAX:
  97. #ifdef    BC_DIM_MAX
  98.       return BC_DIM_MAX;
  99. #else
  100.       return -1;
  101. #endif
  102.  
  103.     case _SC_BC_SCALE_MAX:
  104. #ifdef    BC_SCALE_MAX
  105.       return BC_SCALE_MAX;
  106. #else
  107.       return -1;
  108. #endif
  109.  
  110.     case _SC_BC_STRING_MAX:
  111. #ifdef    BC_STRING_MAX
  112.       return BC_STRING_MAX;
  113. #else
  114.       return -1;
  115. #endif
  116.  
  117.     case _SC_EQUIV_CLASS_MAX:
  118. #ifdef    EQUIV_CLASS_MAX
  119.       return EQUIV_CLASS_MAX;
  120. #else
  121.       return -1;
  122. #endif
  123.  
  124.     case _SC_EXPR_NEST_MAX:
  125. #ifdef    EXPR_NEST_MAX
  126.       return EXPR_NEST_MAX;
  127. #else
  128.       return -1;
  129. #endif
  130.  
  131.     case _SC_LINE_MAX:
  132. #ifdef    LINE_MAX
  133.       return LINE_MAX;
  134. #else
  135.       return -1;
  136. #endif
  137.  
  138.     case _SC_RE_DUP_MAX:
  139. #ifdef    RE_DUP_MAX
  140.       return RE_DUP_MAX;
  141. #else
  142.       return -1;
  143. #endif
  144.  
  145.  
  146.     case _SC_2_VERSION:
  147.       /* This is actually supposed to return the version
  148.      of the 1003.2 utilities on the system {POSIX2_VERSION}.  */
  149.       return _POSIX2_C_VERSION;
  150.  
  151.     case _SC_2_C_BIND:
  152. #ifdef    _POSIX2_C_BIND
  153.       return _POSIX2_C_BIND;
  154. #else
  155.       return -1;
  156. #endif
  157.  
  158.     case _SC_2_C_DEV:
  159. #ifdef    _POSIX2_C_DEV
  160.       return _POSIX2_C_DEV;
  161. #else
  162.       return -1;
  163. #endif
  164.  
  165.     case _SC_2_FORT_DEV:
  166. #ifdef    _POSIX2_FORT_DEV
  167.       return _POSIX2_FORT_DEV;
  168. #else
  169.       return -1;
  170. #endif
  171.  
  172.     case _SC_2_SW_DEV:
  173. #ifdef    _POSIX2_SW_DEV
  174.       return _POSIX2_SW_DEV;
  175. #else
  176.       return -1;
  177. #endif
  178.     }
  179. }
  180.